<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/mui.indexedlist.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/youyi.css"/>
		<link href="css/mui.picker.css" rel="stylesheet" />
		<link href="css/mui.poppicker.css" rel="stylesheet" />
		<style>
			html,
			body{
				height: 100%;
				overflow: hidden;
				background-color: #fff;
			}			
		.mui-btn-blue, .mui-btn-primary, input[type=submit]{border-color: #5ec520; background-color: #5ec520;}
		</style>
	</head>
	<body class="select_city" onbeforeunload="refresh()">
		<header class="mui-bar mui-bar-nav top_nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left detail_left" id="detail_left"></a>
			<h1 class="mui-title">定位</h1>
		</header>
		<div class="mui-content">
			
			<div id='list' class="mui-indexed-list">
				<div class="mui-indexed-list-search mui-input-row mui-search">
					<input type="search" class="mui-input-clear mui-indexed-list-search-input" placeholder="搜索">
				</div>
				<div class="current_city" id="current_city"><a href="javascript:;" class="curent_city_name mui-ellipsis">当前地点是：<span id="city_text">广东省 东莞市</span></a></div>
				<div class="mui-indexed-list-bar">
					<a>A</a>
					<a>B</a>
					<a>C</a>
					<a>D</a>
					<a>E</a>
					<a>F</a>
					<a>G</a>
					<a>H</a>
					<a>I</a>
					<a>J</a>
					<a>K</a>
					<a>L</a>
					<a>M</a>
					<a>N</a>
					<a>O</a>
					<a>P</a>
					<a>Q</a>
					<a>R</a>
					<a>S</a>
					<a>T</a>
					<a>U</a>
					<a>V</a>
					<a>W</a>
					<a>X</a>
					<a>Y</a>
					<a>Z</a>
				</div>
				<div class="mui-indexed-list-alert"></div>
				<div class="mui-indexed-list-inner">
					<div class="mui-indexed-list-empty-alert">没有数据</div>
					<ul class="mui-table-view">
						
					</ul>
				</div>
			</div>
		</div>
		<script src="js/mui.min.js"></script>		
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.indexedlist.js"></script>
		<script src="js/mui.picker.js"></script>
		<script src="js/mui.poppicker.js"></script>
		<script src="js/city.data.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=ZM5FnhEj8ZddP3FpGLM85lPFFVvj1Lgr"></script>
		<script type="text/javascript" charset="utf-8">
			var areas={
				A:["安宁","安庆","鞍山","安顺","安阳","安康"],
				B:["北京","白城","白山","白银","蚌埠","保定","宝鸡","保山","巴中","北海","本溪","滨州","博乐","亳州"],
				C:["沧州","常德","昌吉","常熟","常州","巢湖","朝阳","潮州","承德","成都","城固","郴州","赤壁","赤峰","赤水","池州","崇左","楚雄","滁州","慈溪","从化"],
				D:["大理","大连","丹东","丹阳","大庆","大同","达州","德阳","德州","东莞","东阳","东营","都匀","敦化"],				
				E:["鄂尔多斯","恩施"],				
				F:["防城港","肥城","奉化","抚顺","阜新","阜阳","富阳","福州","抚州"],				
				G:["赣榆","赣州","高明","高邮","格尔木","个旧","巩义","广安","广元","广州","古包头","贵港","桂林","贵阳","固原"],				
				H:["哈尔滨","海城","海口","海门","海宁","哈密","邯郸","杭州","汉中","鹤壁","合肥","衡水","衡阳","和田","河源","菏泽","花都","淮安","淮北","怀化","淮南","黄冈","黄山","黄石","呼和浩特","呼和浩特","惠州","葫芦岛","湖州"],				
				//I:["北京","白城","白山","白银","蚌埠","保定","宝鸡","保山","巴中","北海","本溪","滨州","博乐","亳州"],
				J:["佳木斯","吉安","江都","江门","江阴","胶南","胶州","焦作","嘉善","嘉兴","介休","吉林","即墨","济南","晋城","景德镇","景洪","靖江","荆门",,"荆州","金华","集宁","济宁","晋江","金坛","晋中","锦州","吉首","九江","酒泉","鸡西","济源","句容"],
				K:["开封","凯里","开平","开远","喀什","克拉玛依","库尔勒","奎屯","昆明","昆山"],
				L:["来宾","莱芜","莱西","莱州","廊坊","兰州","拉萨","乐山","连云港","聊城","辽阳","辽源","丽江","临安","临沧","临汾","灵宝","临河","临夏","临沂","丽水","六安","六盘水","柳州","溧阳","龙海","龙岩","娄底","漯河","洛阳","潞西","吕梁","旅顺"],
				M:["马鞍山","茂名","梅河口","眉山","梅州","勉县","绵阳","牡丹江"],
				N:["南安","南昌","南充","南京","南宁","南平","南通","南阳","内江","宁波","宁德"],
				//O:["北京","白城","白山","白银","蚌埠","保定","宝鸡","保山","巴中","北海","本溪","滨州","博乐","亳州"],
				P:["盘锦","攀枝花","蓬莱","平顶山","平度","平湖","平凉","萍乡","普兰店","普宁","莆田","濮阳"],
				Q:["黔南","启东","青岛","庆阳","清远","青州","秦皇岛","钦州","琼海","齐齐哈尔","泉州","曲靖","衢州"],
				R:["日照","荣成","如皋","瑞安","乳山"], 
				S:["三门峡","三明","三亚","佛山","商洛","商丘","上饶","上虞","汕头","安康","韶关","绍兴","邵阳","沈阳","深圳","石河子","石家庄","石林","石狮","十堰","寿光","双鸭山","朔州","沭阳","思茅","四平","松原","遂宁","随州","苏州","宿豫","宿州"],
				T:["塔城","泰安","太仓","泰兴","太原","泰州","台州","唐山","腾冲","滕州","天门","天水","铁岭","铜川","通辽","铜陵","桐庐","铜仁","桐乡","通州","通化","吐鲁番"],				
				//U:["北京","白城","白山","白银","蚌埠","保定","宝鸡","保山","巴中","北海","本溪","滨州","博乐","亳州"],				
				//V:["北京","白城","白山","白银","蚌埠","保定","宝鸡","保山","巴中","北海","本溪","滨州","博乐","亳州"],
				W:["瓦房店","潍坊","威海","渭南","文登","温岭","温州","乌海","武汉","芜湖","吴江","乌兰浩特","武威","无锡","梧州"],
				X:["西安","项城","襄樊","香格里拉","象山","湘潭","湘乡","咸宁","仙桃","咸阳","西藏","西昌","邢台","兴义","新乡","宜城","许昌","徐州",],
				Y:["雅安","牙克石","延安","延边","盐城","阳江","阳泉","扬州","延吉","烟台","兖州","宜宾","宜昌","宜春","伊春","伊犁","银川","营口","鹰潭","伊宁","义乌","宜兴","益阳","永康","永州","岳阳","玉环","榆林","玉林","运城","玉溪","余姚"],
				Z:["枣庄","增城","章丘","漳州","湛江","肇东","肇庆","昭通","郑州","镇江","中山","周口","舟山","诸城","珠海","诸暨","驻马店","株洲","淄博","自贡","遵义"],
			};
			!function(){
				var lis='';
				for(var i in areas){
					var liF='<li data-group='+i+' class="mui-table-view-divider mui-indexed-list-group">'+i+'</li>';
						for(var j in areas[i]){
							var liC='<li class="mui-table-view-cell mui-indexed-list-item">'+areas[i][j]+'</li>';
								liF += liC;
						};
					lis += liF;
				};
				$(".mui-table-view").append(lis);
			}();
			
			mui.init();
//			{
//				beforeback:bkFn()
//			}
//			function bkFn(){
//				var cWebView=plus.webview.currentWebview();
//					console.log(cWebView.id);
//			};
			var textSpan
			mui.ready(function() {
				var header = document.querySelector('header.mui-bar');
				var list = document.getElementById('list');
				//calc hieght
				list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';
				//create
				window.indexedList = new mui.IndexedList(list);
				
				//经纬度
				var lon=null;
				var lat=null;
				
				var map = new BMap.Map("allmap");
				var point = null;
				var gc = new BMap.Geocoder();
				var adres=null;
				var mycity=null;
					textSpan=document.querySelector("#current_city a span");
					navigator.geolocation.getCurrentPosition(function(clbck){
			     		lon=clbck.coords.longitude;
			     		lat=clbck.coords.latitude;
			     		point = new BMap.Point(lon,lat);
			     		geobackFn();
			    });
			    
			    var geobackFn=function(){
			    	gc.getLocation(point, function(rs){
					   var addComp = rs.addressComponents;
					   	   mycity=addComp.city;
					   	   adres=addComp.province + " " + addComp.city + "" + addComp.district + "" + addComp.street +"" + addComp.streetNumber;
					   	   textSpan.innerText=mycity;
							});
			    };
			    
			    	//级联
					var cityPicker3 = new mui.PopPicker({
						layer: 3
					});
					cityPicker3.setData(cityData3);
					var current_city = document.getElementById('current_city');
					var city_text = document.getElementById('city_text');
						current_city.addEventListener('tap', function(event) {
						cityPicker3.show(function(items) {
							sessionStorage.setItem("newCity",(items[1] || {}).text);
							city_text.innerText = (items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text;
							//返回 false 可以阻止选择框的关闭
							//return false;
						});
					}, false);
					
					setTimeout(function(){
						var newCity=sessionStorage.getItem("newCity");
						if(newCity)document.querySelector('#city_text').innerHTML=newCity;
					},3000);
			});
		
		mui(".mui-indexed-list-inner .mui-table-view").on("tap",".mui-indexed-list-item",function(){
			var theHtml=this.innerText;
				textSpan.innerText=theHtml;
				mui.toast('已选择城市为：'+theHtml);
				sessionStorage.setItem("newCity",theHtml);
				setTimeout(function(){
					mui.openWindow('index.html');
				},1000);
		});
		function refresh(){
			console.log("dk");
			window.location.assign("index.html");
			//window.history.forward(1);
			//window.location.href="index.html";
		};
		</script>
	</body>
</html>